#include <QtGui>
#include "stage.h"
//
Stage::Stage() 
{
	_attributes = 0;
}
//
void Stage::setAttributes(AttributesModel *dw)
{
	_attributes = dw;
}
//
Attribute *Stage::attribute(int order)
{
	if(!_attributes) return 0;
	return _attributes->attribute(order);
}
//
bool Stage::changeAttribute(int oldnom,Attribute *label,QTreeWidgetItem *item)
{
	if(item->data(0,Qt::UserRole).toInt()==oldnom){
		item->setData(0,Qt::UserRole,label->order());
		item->setText(0,label->alias());
		return true;
	}
	QTreeWidgetItem *child;
	for(int i=0;i<item->childCount();i++){
		child = item->child(i);
		if(changeAttribute(oldnom,label,child)) return true;
	}
	return false;
}

AttributesModel *Stage::attrModel()
{
	return _attributes;
}
